


#include <iostream>
#include <vector>
using namespace std;

void Test1()
{
    int n = 0, m = 0, q = 0;
    cin >> n >> m >> q;
    vector<vector<int>> v(n, vector<int>(m)), dp(n + 1, vector<int>(m + 1));

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin >> v[i][j];
        }
    }

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j] + v[i - 1][j - 1] - dp[i - 1][j - 1];
        }
    }

    int x1 = 0, x2 = 0, y1 = 0, y2 = 0;
    for (int i = 0; i < q; ++i)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        cout << dp[x2][y2] - dp[x2][y1 - 1] - dp[x1 - 1][y2] + dp[x1 - 1][y1 - 1] << endl;
    }
}

class Solution
{
    vector<int> res;
public:
    // err
    vector<int> grayCode(int n)
    {
        vector<bool> vis(16, false);

        res.push_back(0);
        vis[0] = true;
        _grayCode(pow(2, n) - 1, vis, 1);

        return res;
    }

    vector<int> grayCode(int n)
    {
        vector<int> res(1 << n);

        for (int i = 0, n = res.size(); i < n; ++i)
        {
            res[i] = (i >> 1) ^ i;
        }

        return res;
    }

private:
    bool _grayCode(int cnt, vector<bool>& vis, int index)
    {
        if (res.size() == cnt+1 && check(res.back(), res.front()))
            return true;

        for (int i = 1; i <= cnt; ++i)
        {
            if (!vis[i] && check(i, res[index-1]))
            {
                res.push_back(i);
                vis[i] = true;
                if (_grayCode(cnt, vis, index+1))
                    return true;

                vis[i] = false;
                res.pop_back();
            }
        }

        return false;
    }

    bool check(int a, int b)
    {
        int cnt1 = 0;
        int xorsum = a ^ b;

        while (xorsum)
        {
            xorsum = xorsum & (xorsum - 1);
            ++cnt1;
        }

        return cnt1 == 1;
    }
};

void Test2()
{
    for (const auto& e : Solution().grayCode(2))
    {
        cout << e << " ";
    }
    cout << endl;
}

int main()
{
    //Test1();
    Test2();

    return 0;
}